package com.yingxin.yxerp.module.sys.service.runner;

import com.yingxin.yxerp.module.common.CompanyHelper;
import com.yingxin.yxerp.module.sys.entity.Company;
import com.yingxin.yxerp.module.sys.service.ICompanyService;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;

@Order(1000)
@Component
public class CompanyApplicationRunner implements ApplicationRunner {

    private final ICompanyService companyService;

    public CompanyApplicationRunner(ICompanyService companyService) {
        this.companyService = companyService;
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        List<Company> companyList = companyService.list();
        for (Company company : companyList) {
            CompanyHelper.add1(company.getId(), company.getFullName());
            CompanyHelper.add2(company.getName(), company.getFullName());
        }
    }

}
